package com.example.flyweightpattern.entity;

import java.util.Hashtable;

/**
 * @author ash
 * @description
 * @create 2023/2/23  22:17:19
 * @className FlyweightFactory
 * @verson 1.0.0
 */
public class FlyweightFactory {
    private final Hashtable<Object, Object> flyweights = new Hashtable<>();

    public FlyweightFactory() {
        flyweights.put("X",new ConcreteFlyweight());
        flyweights.put("Y",new ConcreteFlyweight());
        flyweights.put("Z",new ConcreteFlyweight());
    }

    public Flyweight getFlyWeight(String key){
        return (Flyweight) flyweights.get(key);
    }


    public int getFlyWeightsSize(){
        return flyweights.size();
    }
}
